package com.zju.DoctorGo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zju.DoctorGo.entity.Appointment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AppointmentMapper extends BaseMapper<Appointment> {

    @Select("SELECT a.*, p.name AS patientName, d.name AS doctorName FROM appointment a " +
            "JOIN patient p ON a.patient_id = p.userId " +
            "JOIN doctor d ON a.doctor_id = d.userId " +
            "WHERE a.patient_id = #{patientId}")
    List<Appointment> getAppointmentsByPatientId(@Param("patientId") Long patientId);
}
